package com.itheima.manager;
import com.itheima.domain.SmsHomeRecommendProduct;
import com.itheima.service.db.SmsHomeRecommendProductService;
import com.itheima.util.R;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
@Component
public class SmsHomeRecommendProductManager {

    @DubboReference
    SmsHomeRecommendProductService smsHomeRecommendProductService;

    public R addRecommendProduct(@RequestBody List<SmsHomeRecommendProduct> recommendProducts) {
        for (SmsHomeRecommendProduct recommendProduct : recommendProducts) {
            smsHomeRecommendProductService.save(recommendProduct);

        }
        return R.success(null);
    }

    public R deleteBrand(List<Long> ids) {
        smsHomeRecommendProductService.deleteRecommendProduct(ids);
        return R.success(null);
    }

    public R findByPage(Integer pageNum, Integer pageSize,String productName,Integer recommendStatus) {
        return R.success(smsHomeRecommendProductService.findByPage(pageNum, pageSize,productName,recommendStatus));
    }
    public R updateRecommendProduct(List<Long> ids, Integer recommendStatus) {
        for (Long id : ids) {
            smsHomeRecommendProductService.updateRecommendProduct(id,recommendStatus);
        }
        return R.success(null);
    }

    public R updateSortRecommendProduct(Long id, Integer sort) {
        smsHomeRecommendProductService.updateSortRecommendProduct(id,sort);

        return R.success("排序成功");
    }

}
